from django.http import HttpResponse
from django.shortcuts import render

from blog.models import Car, User
from urllib.parse import unquote

def handle(request):
    if request.method == 'POST':
        car_id = unquote(request.POST.get('carId'))
        user_id = request.session['id']
        car = Car.objects.get(id=car_id)
        user = User.objects.get(id=user_id)
        car.handle.add(user)
        return HttpResponse("收藏成功")